<template>
  <div class="index-container">
    <Header left="arrow" title="红包卡券"></Header>
    <div class="body-wrapper">
      <van-tabs v-model="active">
        <van-tab title="可使用">
          <CouponCard
            :contents="contents"
            @click.native="isShow(index)"
          />
          <van-dialog v-model="show" title="标题" show-cancel-button>
            是否使用该{{ dialogValue }}？
          </van-dialog>
        </van-tab>
        <van-tab title="已使用">内容 2</van-tab>
        <van-tab title="已失效">内容 3</van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import { Tab, Tabs, Card, Dialog } from "vant";
import Header from "@/components/Header";
import CouponCard from "@/components/CouponCard.vue";

Vue.use(Tab).use(Tabs).use(Card).use(Dialog);
export default {
  data() {
    return {
      active: 0,
      contents: [
        {
          title: "外卖免配送费券",
          subContent: "配送券",
          num: "0",
          unit: "元",
          startTime: "2022.05.18",
          endTime: "2022.06.19",
        },
        {
          title: "限定饮品9折券",
          subContent: "折扣券",
          num: "9",
          unit: "折",
          startTime: "2022.05.18",
          endTime: "2022.06.19",
        },
      ],
      show: false,
      dialogValue: "",
    };
  },

  components: {
    Header,
    CouponCard,
  },

  methods: {
    isShow(index) {
      this.show = true;
      for(const k in this.contents){
          this.dialogValue = this.contents[k].subContent
      }
    },
  },
};
</script>

<style scoped>
::v-deep .van-tabs__content {
  padding-top: 5px;
}
::v-deep .van-dialog {
  width: 80%;
  margin: 0 auto;
}
::v-deep .van-dialog__header {
  padding-top: 10px;
}
::v-deep .van-dialog__content {
  padding: 10px 0;
  text-align: center;
}
.header {
  position: fixed;
  height: 2.13rem;
  line-height: 1.457rem;
  left: 0px;
  top: 0px;
  right: 0px;
}
.header_title {
  height: 2.13rem;
  line-height: 2.803rem;
}
.van-nav-bar {
  box-shadow: none;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.14901960784313725);
}
.body-wrapper {
  position: absolute;
  top: 80px;
  width: 100%;
}
.couponCard {
  width: 90%;
  margin: 0 auto;
  background-color: #fff;
}
.couponCard .cardContent p:first-child {
  font-weight: 600;
  font-size: 14px;
  margin: 0;
}
</style>